Repository navigation
Browser tests wait for the page to be still, not a fixed time - #2309
Merged
Merged
Conversation
The browser layout tests draw a screen, add the app's stylesheet after it has drawn, and measure or photograph it. The late styles start the transitions they declare (a dialog sliding into place, a fade, rows easing in), and about forty files then waited a fixed 150 to 1000ms before measuring. Under a full CI run, eight files at once in Chromium and WebKit, that guess was sometimes short and the test read a screen mid-move. They now call one shared helper, still(page) in app/tests/page-still.ts, which waits until, for three frames in a row, no animation that ends is running and nothing in the document changed. Endless and scroll-driven animations do not count, since they never end on their own (waiting on a scroll-driven one's finished never returns). A page that never stops fails with what kept moving. no-fixed-settle-waits.test.ts keeps it that way: a file under app/tests that calls waitForTimeout fails unless it is listed with the most waits it may hold and why (a wait that proves something does not happen, a timer under test, a poll).
davidmckayv
requested review from
MikeRyanDev,
dustywusty,
guidovizoso,
mxmzb,
samjulien and
tylerslaton
as code owners
November 27, 2026 08:11
The sidebar's orb breathes by writing its own scale every frame, so a page with it never stopped changing and the narrow sheet test could not go still. Read every element's laid-out box instead (offsets, before transforms): a transform that never ends no longer counts, and anything that lays out again still does. The failure now names the element that moved and where.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was flaky
The browser layout tests under
app/testsdraw a screen, add the app's stylesheet after it has drawn, and then measure or photograph it. They failed now and then in CI, most often in WebKit: a dialog measured off the screen, a colour read mid-fade, a row measured before it had laid out again.The cause
Styles that arrive after the page has drawn start the transitions they declare: a dialog slides from where it sat unstyled to the middle of the window, a button fades from the browser's own colour to its own, rows ease in. About forty files then waited a fixed time (
page.waitForTimeout(400), or 150 to 1000ms) and measured. Under a full CI run, eight files at once in Chromium and WebKit, that guess was sometimes short. #2302 fixed one file; the others each had their own copy of the same guess.The fix
One shared helper,
still(page)inapp/tests/page-still.ts, replaces every one of those settle waits (40 files, plus the one from #2302). It waits for fonts, then until, for three frames in a row:Endless animations (spinners, shimmers) and scroll-driven ones (the transcript's scroll fade) are left out, because they never end on their own; waiting on a scroll-driven animation's
finishednever returns. Boxes are read before transforms, so the sidebar orb, which scales itself every frame, does not keep a page from being still. A page that never goes still fails after 10 seconds and names what kept moving.What each test asserts is unchanged. Two files' teardown also gets 30 seconds to close its browsers: under eight files at once, closing two browsers sometimes took longer than a hook's default five.
The lock
app/tests/no-fixed-settle-waits.test.tsfails when any file underapp/testscallswaitForTimeout, unless the file is listed with the most fixed waits it may hold and a one-line reason. The listed ones prove something does not happen within a time (no second tab opens, a read is not asked again), let a timer under test run, or poll something the page cannot be asked about.CI proof
A temporary job, removed before merge, ran the 40 changed files plus the 9 that use the shared notices helper (49 files) together with
bun test --parallel=8, in Chromium and WebKit, in the Playwright v1.62.1 image on the 16-core runner.sidebar-current-rowandsidebar-window-buttons, two files no CI job runs. A baseline job ran those two files from main and they fail the same 4 tests there, so they were already broken before this change.The normal CI jobs (Chromium list, WebKit list) pass on this head.